from django.db import models

# Create your models here.


class User(models.Model):
    email = models.EmailField(unique=True)
    password = models.CharField(max_length=160)
    state = models.SmallIntegerField(default=0)
    c_time = models.DateTimeField(verbose_name='创建时间',auto_now_add=True)
    u_time = models.DateTimeField(verbose_name='修改时间',auto_now=True)

    class Meta:
        db_table = 'user'


class UserDetail(models.Model):
    nickname = models.CharField(verbose_name='昵称',max_length=40,null=True,unique=True)
    portrait = models.TextField(verbose_name='头像',null=True)
    phone = models.CharField(max_length=11,null=True,unique=True)
    age = models.SmallIntegerField(null=True)
    sex = models.SmallIntegerField(default=1)
    adddress = models.TextField(null=True)
    birthday = models.DateField(null=True)
    user = models.OneToOneField('User',on_delete=models.CASCADE,related_name='detail')

    class Meta:
        db_table = 'user_detail'





